﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<title></title>
	</head>
	<body>
	
	    <h1 title="Interprocess Communication Library">
            Interprocess Communication Library</h1>
    <address>
        IPCLibrary<br />
        Managed Library for Inter Process Communication<br />
        Copyright(C) 2008 Bill Tudor<br />
    </address>
    <h2>
        Overview</h2>
    <p>
        The .Net framework class library contains many options for Interprocess 
        communication including remoting, WCF services, sockets, and, with framework 2.0 
        or later, anonymous pipes and named pipes. This library wraps additional Win32 
        IPC mechanisms in an attempt to complete the IPC picture for managed code. This 
        library provides an implementation for Mailslots, Memory Mapped Files, and 
        Shared Memory. For the most part, this implementation is a thin wrapper around 
        Win32 API functions, wowever, an attempt was made to expose an object oriented 
        abstraction for the programmer. These abstractions are exposed in the following 
        public types:</p>
<p>
        <b>Mailslot</b></p>
<p>
        Provides a <i>mailsot</i> that can be read using either synchronous or 
        asynchronous methods, or automatically monitored/read asynchronously and sinked 
        through an event raised when a message arrives. This object can be thought of as 
        a mailslot server. Messages can be read as either binary blobs or strings.</p>
<p>
        <b>MailslotClient</b></p>
<p>
        Provides a simple object that can be used to write messages to a <i>mailslot</i>. 
        You can write both string messages as well as binary blobs.</p>
<p>
        <b>MemoryMappedFile</b></p>
<p>
        This object provides an abstraction for <i>memory mapped files </i>- backed by 
        files on disk or the system paging file. Named mappings can be shared across 
        process boundries. This class exposes a <i>GetStream</i>() method which provides 
        stream-based access to read and write data to and from the file.</p>
<p style="font-weight: 700">
        SharedMemory</p>
<p>
        The <i>SharedMemory</i> object exposes shared memory stored in a conventional 
        Win32 &quot;shared data&quot; dynamic link library, i.e., a library with an exported data 
        block contained in a shared data segment (an example of such a thing is provided 
        with the source code). Multiple processes can share this data through the use of 
        this object. The data may be structured in any manner you desire, however, this 
        class treats the data as a simple blob of bytes of a given size. methods are 
        provided to read and write blocks of bytes. A <i>GetStream</i>() method will 
        return a Stream object that can be used to read and write data, or be used with 
        BinaryReader and BinaryWriter objects for more convenient data access.</p>
	
	<p>
        IPC is inheriently a multi-threaded programming endevor. The IPC library 
        contains objects and methods that are thread-safe , however, successully reading 
        and writing to shared memory (memory mapped files or DLL shared memory) must be 
        coordinated through the use of synchronization objects (such as named mutexes) 
        that are already available in the .Net framework library. An assumption is made 
        in this library design and documentation that the reader is aware of these 
        issues.</p>
    <p>
        The IPCLibrary throws only one exception type - IPCException. Additional 
        details, if available, will be found in the inner exception member. All failed 
        Win32 API calls will result in an IPCExcpetion that includes the error code from 
        GetLastError().</p>
    <h2>
        <a name="Project">Project</a> Structure and Organization</h2>
    <p>
        The following projects are included:</p>
    <p>
        <b>IPCLibrary</b> - Code library project. You can either reference this project 
        or its output (IPCLibrary.dll) in your applications.</p>
    <p>
        <b>IPCLibraryDoc</b> - Documentation project. This project is essentially an 
        MSBUILD script that produces a documentation file (compiled help file) 
        containing the project documentation and API documentation. There are actually 
        two build scripts - one that builds API documentation (via sandcastle), which 
        must be run &quot;manually&quot; via msbuild on the command line, i.e., there is no visual 
        studio tool integration for this part of the documentation build process. You 
        must have sandcastle installed for this build to work. The script is named 
        &quot;sandcastle.proj&quot; and produces the file &quot;apidoc.chm&quot; in the CHM folder under the 
        documentation project root. The visual studio project &quot;IPCLibraryDoc&quot; builds the 
        compiled help file &quot;IPCLibrary.chm&quot;, which contains a link to the apidoc CHM 
        file. Both files must be present in the distribution package.</p>
    <p>
        <b>IPCLibraryTest</b> - Unit test project. This project is a visual studio unit 
        test application. The projects provides about 90% test coverage on the library.</p>
    <p>
        <b>IPCLibraryTestApp</b> - Test application. This project is a Windows Forms 
        application that can be used to exercise the object model exposed in the 
        library. Running two instances of this application will allow you to send 
        messages to a mailslot, write data to shared memory, and write data to named 
        memory mapped file from one process, and receive that data in another process.</p>
    <p>
        <b>Data</b> - Shared data library project. This project is a Win32 C++ dynamic 
        link library project that defines one exported variable (named &quot;data&quot;) in a 
        shared data segment. This library is used by both the unit tests and the 
        IPCLibraryTestApp for exercising the SharedMemory object. You can use this 
        project as a model for utilizing shared memory in your own applications.</p>
	
	</body>
</html>